﻿using EFDemo.Chapte2.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace EFDemo.Chapte2.ModelMapConfigs
{
    public class StudentConfig : IEntityTypeConfiguration<Student>
    {
        public void Configure(EntityTypeBuilder<Student> builder)
        {
            builder.HasKey(s => s.Id);
            builder.Property(s => s.Name).HasMaxLength(64);
            builder.HasOne(s => s.Teacher).WithMany(t => t.Students).HasForeignKey(s => s.TeacherId);
        }
    }
}
